<?php


namespace app\common\model;


class UserTask extends BaseModel
{
    protected $name = "user_task";


    public function user()
    {
        $module = static::getCalledModule() ?: 'common';
        return $this->BelongsTo("app\\{$module}\\model\\User",'user_id','user_id');
    }
    public function coach(){
        return $this->belongsTo("app\\common\\model\\Coach");
    }
    public function file()
    {
        return $this->belongsTo('UploadFile', 'file_id', 'file_id')
            ->bind(['file_path', 'file_name', 'file_url','file_type']);
    }
    public function fileimage()
    {
        return $this->belongsTo('UploadFile', 'image_id', 'file_id');
    }
    //关联预约表
    public function reservation(){
        return $this->belongsTo('app\\common\\model\\Reservation','reservation_id','id');
    }

    public static function detail($where)
    {
        return static::get($where,['user','coach','reservation']);
    }
}